<template>
  <div class="">
    <el-row>
      <!-- <el-col :span="24">
        <div class="page-filter mb10 fl">
          <el-form ref="filter" :model="filter" label-width="0">
            <el-form-item class="mr10 mb5 fl">
              <SupplierSelect v-model="filter.sup_id" />
            </el-form-item>
            <el-form-item class="mr10 mb5 fl" style="width: 300px">
              <el-button size="small" @click="app.resetFields($refs['filter'].$parent,'filter')">清 空</el-button>
              <el-button type="primary" size="small" @click="getList">查 询</el-button>
            </el-form-item>
          </el-form>
        </div>
      </el-col> -->
      <el-col :span="24">
        <el-table
          v-loading="app.loading"
          class="search-table"
          :data="list"
          border
          :summary-method="getSummaries"
          show-summary
          fit
          highlight-current-row
          style="width: 100%;"
        >
          <el-table-column label="序号" align="center" width="56px">
            <template slot-scope="{$index}">
              {{ $index + 1 }}
            </template>
          </el-table-column>
          <el-table-column label="姓名" width="220px" prop="nickname"/>
          <el-table-column label="累计暂支" align="right" width="140px">
            <template slot-scope="{row}">
              <a style="color: blue" 
                @click="handleDialog({...{su_id: row.su_id}, ...
                    {dRef: 'reimbursement', dTitle: '暂支详情', dType: 'edit', dField: dField}})"
                >{{ app.toFix(row.money-row.pay_money, 2) }}</a><br>
            </template>
          </el-table-column>
          <el-table-column label="累计报销金额" align="right" width="140px">
            <template slot-scope="{row}">
              <a style="color: blue" 
                @click="handleDialog({...{su_id: row.su_id}, ...
                    {dRef: 'reimbursementPay', dTitle: '报销详情', dType: 'edit', dField: dField}})"
                >{{ app.toFix(row.fp_money, 2) }}</a><br>
            </template>
          </el-table-column>
          <el-table-column label="应退金额" align="right" width="140px">
            <template slot-scope="{row}">
              <span v-if="(row.money-row.pay_money-row.fp_money) >= 0">{{ app.toFix(row.money-row.pay_money-row.fp_money, 2) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="应付金额" align="right" width="140px">
            <template slot-scope="{row}">
              <span v-if="(row.money-row.pay_money-row.fp_money) <= 0">{{ app.toFix(row.pay_money+row.fp_money-row.money, 2) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="备注" align="center" min-width="220px">
            <template slot-scope="{row}">
              
            </template>
          </el-table-column>
        </el-table>
        <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
      </el-col>
    </el-row>
    <Reimbursement ref="reimbursement" :info="dialog" />
    <ReimbursementPay ref="reimbursementPay" :info="dialog" />
  </div>
</template>

<script>
import { reimbursements } from '@/api/statistics/statistics'
import page from '@/utils/page'
import Reimbursement from './components/reimbursements-dialog'
import ReimbursementPay from './components/reimbursements-pay-dialog'

export default {
  name: '',
  components: { Reimbursement, ReimbursementPay },
  extends: page,
  props: {
    reqList: {
      default: reimbursements,
      type: Function
    }
  },
  data() {
    return {
      dField: ['su_id'],
      price: {}
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getListAfter(e) {
      this.price = e.info || {}
    },
    getSummaries() {
      const sums = []
      sums[0] = '合计'
      sums[1] = ''
      sums[2] = this.app.toFix(this.price.money - this.price.pay_money, 2)
      sums[3] = this.app.toFix(this.price.fp_money, 2)
      if(this.price.money - this.price.pay_money - this.price.fp_money > 0) {
        sums[4] = this.app.toFix(this.price.money - this.price.pay_money - this.price.fp_money, 2)
        sums[5] = ''
      }else{
        sums[4] = ''
        sums[5] = -this.app.toFix(this.price.money - this.price.pay_money - this.price.fp_money, 2)
      }
      return sums
    }
  }
}
</script>
<style scoped>
</style>
